home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / utils sync / JetSync 1.0 / jetsync-1.0.exe / jetsync-1.0 / src / synchronize.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-27  |  1.2 KB  |  56 lines

  1. #include "defs.h"
  2. #include "Comm.h"
  3. #include "Database.h"
  4. #include "Random.h"
  5. #include "hotsync.h"
  6. #include "assert.h"
  7.  
  8. /* these external variables are defined in main.c */
  9. extern unsigned long pc_id; /* PC Id read from global prefs file on startup */
  10. extern char username[256];
  11.  
  12. /* pilot socket */
  13. int sd;
  14.  
  15.  
  16. /* performs the entire synchronization algorithm. This function is called in
  17.    Tcl/Tk or directly from C in case a daemon is running */
  18. /* Arguments: none */
  19. /* Returns: always 0 (TCL_OK) */
  20. __TCL__ int HOTSYNCMANAGER()
  21. {
  22.   int size;
  23.   struct PilotUser U;
  24.   struct DBList *list;
  25.   int code;
  26.   char path[256], logbuffer[1024]="";
  27.  
  28. #ifdef __DEBUG
  29.   printf("%s started: User is '%s'\n",__FILE__,username);
  30. #endif
  31.  
  32.   init_random_generator();
  33.   pc_id = generate_pc_id();
  34.  
  35.   code = Tcl_Eval(g_interp, "progress -1 0 \"Synchronizing...\"");
  36.   
  37.   if (js_Start(&sd, &U, username, path) < 0) {
  38.     js_CloseComm(sd, &U, logbuffer);
  39.  
  40.     strcpy(g_interp->result, "-1");
  41.     return TCL_OK; /* not ok, but fool tcl/tk */
  42.   }
  43.  
  44.   js_Connect(sd, &list, &size);
  45.  
  46.   js_Synch(sd, &U, list, size, path, logbuffer);
  47.  
  48.   free(list);
  49.  
  50.   js_CloseComm(sd, &U, logbuffer);
  51.   code = Tcl_Eval(g_interp, "killprogress");
  52.  
  53.   strcpy(g_interp->result, username);
  54.   return TCL_OK;
  55. }
  56.